package com.hikvision.rpq.sblearn.config;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * 后置处理器
 * @author renpeiqian
 * @date 2021/9/27 19:24
 * @since
 */
@Component
public class MyBeanPostProcessor implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if ("user".equals(beanName)){
            System.out.println("MyBeanPostProcessor before方法拦截 user");
        }
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if ("user".equals(beanName)){
            System.out.println("MyBeanPostProcessor after方法拦截 user");
        }
        return bean;
    }
}
